package com.hospital.workstation.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.hospital.common.annotation.RepeatSubmit;
import com.hospital.common.annotation.Log;
import com.hospital.common.core.controller.BaseController;
import com.hospital.common.core.domain.PageQuery;
import com.hospital.common.core.domain.R;
import com.hospital.common.core.validate.AddGroup;
import com.hospital.common.core.validate.EditGroup;
import com.hospital.common.core.validate.QueryGroup;
import com.hospital.common.enums.BusinessType;
import com.hospital.common.utils.poi.ExcelUtil;
import com.hospital.workstation.domain.vo.HisDocumentSearchVo;
import com.hospital.workstation.domain.bo.HisDocumentSearchBo;
import com.hospital.workstation.service.IHisDocumentSearchService;
import com.hospital.common.core.page.TableDataInfo;

/**
 * 检验检查报告调阅
 *
 * @author whb
 * @date 2023-03-09
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/workstation/documentSearch")
public class HisDocumentSearchController extends BaseController {

    private final IHisDocumentSearchService iHisDocumentSearchService;

    /**
     * 新增检验检查报告调阅
     */
    @SaCheckPermission("workstation:documentSearch:add")
    @Log(title = "检验检查报告调阅", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HisDocumentSearchBo bo) {
        return toAjax(iHisDocumentSearchService.insertByBo(bo));
    }

    /**
     * 查看报告
     *
     * @param documentId 文档ID
     * @return
     */
    @SaCheckPermission("workstation:documentSearch:report")
    // @RepeatSubmit()
    @GetMapping("/report/{documentId}")
    public R<HisDocumentSearchVo> queryReportByDoucument(@PathVariable String documentId) {
        return iHisDocumentSearchService.queryReportByDocument(documentId);
    }
}
